import Axios from '../utils/axios'
import api from '../api'

// 添加会员卡信息
function addVipCard(addVipCard:Array<any>){
	return Axios.post(api.UserManagement.add_vipCard,{addVipCard});
}

// 删除会员卡信息
function delVipCard(id:number){
	return Axios.delete(api.UserManagement.del_vipCard+"/"+id);
}

// 会员卡信息分页
function pageVipCard(cardType:number,limit:number,name:string,page:number){
	return Axios.post(api.UserManagement.page_vipCard,{cardType,limit,name,page});
}

// 更改会员卡信息
function changeVipCard(changeVipCard:Array<any>){
	return Axios.put(api.UserManagement.change_vipCard,{changeVipCard});
}

// 搜索会员卡信息byid
function searchVipCardById(id:number){
	return Axios.get(api.UserManagement.search_vipCard_by_id+"/"+id);
}

// 添加会员卡等级
function addVipLevel(defaultUse:number,discount:string,integralRequirement:number,name:string){
	return Axios.post(api.UserManagement.add_vipLevel,{defaultUse,discount,integralRequirement,name});
}

// 删除会员卡等级
function delVipLevel(id:number){
	return Axios.delete(api.UserManagement.del_vipLevel+"?id="+id);
}

//查询会员卡等级
function pageVipLevel(){
	return Axios.get(api.UserManagement.page_vipLevel);
}

//更改会员卡等级
function changeVipLevel(id:number,name:string,defaultUse:number,integralRequirement:number,discount:string,createTime:string){
	return Axios.put(api.UserManagement.change_vipLevel,{id,name,defaultUse,integralRequirement,discount,createTime});
}

//搜索会员卡等级byid
function searchVipLevelById(id:number){
	return Axios.get(api.UserManagement.search_vipLevel_by_id+"/"+id);
}

//查询用户所有收获地址
function searchAddressByUserId(userId:number){
	return Axios.get(api.UserManagement.searchAddressByUserId+"?userId="+userId);
}

//添加用户会员卡信息
function addUserVipCard(cardId:number,userId:number,venuesId:number){
	return Axios.post(api.UserManagement.addUserVipCard,{cardId,userId,venuesId});
}

//改变用户会员卡状态
function changeUserVipCardStatus(cardStatus:number,id:number){
	return Axios.put(api.UserManagement.changeUserVipCardStatus,{cardStatus,id});
}
 
//根据用户会员卡id查看用户会员卡信息
function getUserCardInfo(id:number){
	return Axios.get(api.UserManagement.getUserCardInfo+"/"+id);
}

//会员卡续费
function renewal(change:string,illustrate:string,money:number,userCardId:number){
	return Axios.post(api.UserManagement.renewal,{change,illustrate,money,userCardId});
}
 
//查看用户会员卡分页信息
function userVipCardPageList(cardStatus:number,limit:number,page:number,queryName:string){
	return Axios.post(api.UserManagement.userVipCardPageList,{cardStatus,limit,page,queryName});
}

//根据用户id查询用户会员卡信息
function getUserCardInfoByUserId(userId:number){
	console.log("serves",userId);
	return Axios.get(api.UserManagement.getUserCardInfoByUserId+"?userId="+userId);
}

//根据用户会员卡id查询所有消费记录
function cardConsumeRecord(id:number){
	return Axios.get(api.UserManagement.cardConsumeRecord+"/"+id);
}

//用户分页信息
function getUserPageList(createTime:string,limit:string,name:string,page:number,phone:string){
	return Axios.post(api.UserManagement.getUserPageList,{createTime,limit,name,page,phone});
}

//根据id查询用户信息
function userById(id:number){
	// console.log("请求Id",id)
	return Axios.get(api.UserManagement.userById+id);
}

// 跟新积分规则
function integralRuleUpdate(buy:number,continuousDay:number,deductions:number,deductionsPercentage:number,extra:number,id:number,punchRewards:number){
	return Axios.put(api.UserManagement.integralRuleUpdate,{buy,continuousDay,deductions,deductionsPercentage,extra,id,punchRewards});
}

//根据id查找积分规则信息
function integralRuleById(id:number){
	return Axios.get(api.UserManagement.integralRuleById+"/"+id);
}

//添加教练
function coachAdd(id:number){
	return Axios.get(api.UserManagement.integralRuleById+"/"+id);
}

//删除教练
function coachDeleteById(id:number){
	return Axios.get(api.UserManagement.integralRuleById+"/"+id);
}

//查询所有教练
function coachFindAll(){
	return Axios.get(api.UserManagement.coachFindAll);
}

//根据id查询教练
function coachFindById(id:number){
	return Axios.get(api.UserManagement.integralRuleById+"/"+id);
}

//编辑教练信息
function coachUpdate(id:number){
	return Axios.get(api.UserManagement.integralRuleById+"/"+id);
}



export default{
	addVipCard,
	delVipCard,
    pageVipCard,
    changeVipCard,
    searchVipCardById,
	addVipLevel,
	delVipLevel,
	pageVipLevel,
	changeVipLevel,
	searchVipLevelById,
	searchAddressByUserId,
	addUserVipCard,
	changeUserVipCardStatus,
	getUserCardInfo,
	renewal,
	userVipCardPageList,
	getUserCardInfoByUserId,
	cardConsumeRecord,
	userById,
	getUserPageList,
	integralRuleUpdate,
	integralRuleById,
	coachAdd,
	coachDeleteById,
	coachFindAll,
	coachFindById,
	coachUpdate,
}